package org.example.tinyurl.algorithm;

import org.apache.shardingsphere.api.sharding.standard.RangeShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.RangeShardingValue;

import java.util.Arrays;
import java.util.Collection;

/**
 * @author: zk
 * @date: 2023/6/21 19:17
 * 定制范围查找时分表查找策略
 */
public class MyTableRangeAlgorithm implements RangeShardingAlgorithm<Long> {
    @Override
    public Collection<String> doSharding(Collection<String> collection, RangeShardingValue<Long> rangeShardingValue) {
        String logicTableName = rangeShardingValue.getLogicTableName();
        // 范围查询表
        return Arrays.asList(logicTableName + "_1", logicTableName + "_2", logicTableName + "_3", logicTableName + "_4");
    }
}
